package com.hdkj.eduservice.controller;

import com.hdkj.commonutils.R;
import com.hdkj.eduservice.entity.subject.OneSubject;
import com.hdkj.eduservice.service.ArtSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/eduservice/artsubject")
public class ArtsubjectController {
    @Autowired
    private ArtSubjectService artSubjectService;

    //保存（添加文章分类）

    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        artSubjectService.saveSubject(file,artSubjectService);
        return R.ok();
    }


    //文章分类列表（树形）
    @GetMapping("getAllSubject")
    public R getAllSubject() {
        //list集合泛型是一级分类
        List<OneSubject> list = artSubjectService.getAllOneTwoSubject();
        return R.ok().data("list",list);

    }


}
